#include<iostream>
using namespace std;
void move(char x,char y,char z,int n)
{
	if(n<=0) return ;
	move(x,z,y,n-1);
	printf("%c->%d->%c\n",x,n,y);
	move(z,y,x,n-1);
}


int main()
{
	int n;
	char a,b,c;
	cin>>n;
	cin>>a>>b>>c;
	move(a,b,c,n);
}